<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>项目转办记录表 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">项目名称</div>
                    <div class="field">
                        <input name="prjNm" id="prjNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">合同号</div>
                    <div class="field">
                        <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox col_33" >
                    <div class="label">创建时间</div>
                    <div class="field">
                        <input name="stDt" id="stDt" type="text" class="ui-datepicker" value="">
                        <span>---</span>
                        <input name="endDt" id="endDt" type="text" class="ui-datepicker" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">部门</div>
                    <div class="field">
                        <select name="buOrgCd" id="buOrgCd">
                            <option value=" " seleted>请选择</option>
                            <c:forEach items="${orgListList }" var="org">
                                <option value="${org.key }">${org.value }</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">创建人</div>
                    <div class="field">
                        <input name="crtUsrNm" id="crtUsrNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <%--<div class="fieldBox">
                    <div class="label">所属区域</div>
                    <div class="field">
                        <select name="cstMgrRgnCd" id="cstMgrRgnCd">
                            <option value=" " seleted>请选择</option>
                            <c:forEach items="${regionList }" var="org">
                                <option value="${org.key }">${org.value }</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>--%>

                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round">筛选</span>
                    <%--<span id="searchBtn" class="sq-button sq-button-round">导出</span>--%>
                    <%--<span id="clearBtn" class="sq-button sq-button-round">清空</span>
                    <span id="addBtn" class="sq-button sq-button-round">新增</span>
                    <span id="changeBtn" class="sq-button sq-button-round">修改</span>
                    <span id="delBtn" class="sq-button sq-button-round">删除</span>--%>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null,callback=null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/project/prjTransLog/initList.do',
            method: 'get',
            columns: [
                { display: '项目名称', name: 'prjNm', align:'left',minWidth: 140 ,
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        if(value&&value!="null"){
                            h+='<a href="javascript:detailBtn(';
                            h+="'"+rowdata.prjId+"'";
                            h+=')">'+value+'</a>'
                        }
                        return h;
                    },
                    enabledSort:true},
                {display: '合同号', name: 'lsCntNo', minWidth: 140 , enabledSort:true},
                {display: '客户', name: 'cstNm', minWidth: 140,align:'center', enabledSort:true},
                {display: '创建人', name: 'crtUsrNm', minWidth: 140,align:'center', enabledSort:true},
                {display: '当前负责人', name: 'newCstMgrNm', minWidth: 140,align:'center', enabledSort:true},
                {display: '所属机构', name: 'buOrgCdNm', width: 100, enabledSort:true},
                {display: '省公司', name: 'prOrgCdNm', width: 100 , enabledSort:true},
                {display: '分公司', name: 'cyOrgCdNm', width: 100 , enabledSort:true},
                {display: '项目类型', name: 'prjTypCdNm', width: 150, enabledSort:true},
                {display: '业务模式', name: 'bizTypCdNm', minWidth: 140 , enabledSort:true},
                /*{display: '所属区域', name: 'newCstMgrRgnCdNm', width: 100, enabledSort:true},*/
                {display: '创建时间', name: 'crtTm', minWidth: 100 , render:renderDate, enabledSort:true}

            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            //isScroll: false,
            checkbox: true,
            rownumbers: true,
            delayLoad:false,
            allowUnSelectRow: true,
            alternatingRow: false
            /* onRenderComplete: function () {
             iframeResize ();
             } */
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function(event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            data["crtTm"] = $("#crtTm").val();
            for (name in data){
                grid.setParm(name,data[name]);
            };
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });

        callback = function () {
            grid.reload();
        };

        /* 新增 */
        $("#addBtn").click(function (event) {
            $.ligerDialog.open({
                width: 550,
                height: 500,
                title: '新增项目转办记录表',
                url:'<%=path%>/project/prjTransLog/toAddPage.do'
            });
            //Add_navTab("PrjTransLog_1", "新增项目转办记录表", '<%=path%>/project/prjTransLog/toAddPage.do', callback);
        });

        /* 修改 */
        $("#changeBtn").click(function (event) {
            var selectedRows = grid.getSelectedRows();
            if (selectedRows.length != 1) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
                return;
            }
            var _id=selectedRows[0].id;
            $.ligerDialog.open({
                width: 550,
                height: 500,
                title: '修改项目转办记录表',
                url:'<%=path%>/project/prjTransLog/toModifyPage.do?id='+_id
            });
            //Add_navTab('PrjTransLog_2'+_id, "修改项目转办记录表", '<%=path%>/project/prjTransLog/toModifyPage.do?id='+_id, callback);
        });

        /* 删除 */
        $("#delBtn").click(function () {
            var selectedRows = grid.getSelectedRows();
            if (selectedRows.length == 0) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW, SQ_type: "warning"});
                return;
            }
            var _ids = [];
            for (var index in selectedRows) {
                _ids.push(selectedRows[index].id);
            }

            $.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
                if (flag == false)return;
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: {ids: JSON.stringify(_ids)},
                    url: '<%=path%>/project/prjTransLog/removeByIds.do',
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({
                            content: LogUtils.LOG_CMM_DATA_LOADING,
                            SQ_type: "waitting"
                        });
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            grid.reload();
                        } else {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });
            });
        });

    });


    //格式化时间
    function renderDate(rowdata, index, value){
        var dateStr = "";
        if(null != value){
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }


    function detailBtn(id){
        /* var selectedRows = grid.getSelectedRows();
        if(selectedRows.length != 1){
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warring"});
            return;
        }

        var id = selectedRows[0].id; */
        var fromPrjFlag = true;
        var detailFlag = true;

        var _flag = $("#fromPrjFlagId").val();//来自哪里
        if(StringUtils.isNotEmpty(_flag)){
            if(_flag == 'false'){
                fromPrjFlag = false;
            }
        }

        Add_navTab('tab_project_detail'+id,'项目详情','<%=path%>/project/prjbscinfo/toModifyPage.do?fromPrjFlag='+fromPrjFlag+'&&id='+id+'&&detailFlag='+detailFlag);
    }

</script>

</body>
</html>
